<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>入驻品牌</title>
</head>
<body>
	<form id="fm">
		<div class="form-group">
			<label for="formGroupExampleInput">品牌入驻</label> <input type="text"
				class="form-control" id="formGroupExampleInput"
				placeholder="请输入品牌名称" name="name">
		</div>
		<div class="form-group">
			<label for="exampleFormControlFile1"></label> <input type="file"
				name="filePic" "form-control-file" id="exampleFormControlFile1">
		</div>
	</form>
	<!-- button写在form表单外,避免点击button自动提交form -->
	<button class="btn btn-primary" onclick=add()>添加</button>


	<script type="text/javascript">
		function add(){
			//$("#fm").serialize();  有图片上传这种方式不可行
			var formData = new FormData($("#fm")[0]);

			$.ajax({

				url: 'brand/add',
				type: 'post',
				data: formData,
				processData:false,
				contentType:false,
				success: function(resp){
					if(resp){
						alert("success!")
						$("#workArea").load("/brand/list");
					}else{
						alert("fail!!!")
					}
				}
			})
				
		}
		
	</script>
</body>
</html>